home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 23 / AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso / Tools / HRTmon / src / copper.s < prev    next >
Text File  |  1999-11-06  |  5KB  |  261 lines

  1.  
  2. ;HRTmon Amiga system monitor
  3. ;Copyright (C) 1991-1998 Alain Malek Alain.Malek@cryogen.com
  4. ;
  5. ;This program is free software; you can redistribute it and/or
  6. ;modify it under the terms of the GNU General Public License
  7. ;as published by the Free Software Foundation; either version 2
  8. ;of the License, or (at your option) any later version.
  9. ;
  10. ;This program is distributed in the hope that it will be useful,
  11. ;but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;GNU General Public License for more details.
  14. ;
  15. ;You can find the full GNU GPL online at: http://www.gnu.org
  16.  
  17. ;-------------- Search copper-list -----------------------------
  18.  
  19. cmd_cop        moveq    #0,d5
  20.         move.l    max_chip,d6
  21.         bsr    evaluate
  22.         bmi.w    illegal_addr
  23.         bgt.w    .norange
  24.         move.l    d0,d5
  25.         and.w    #$fffe,d5
  26.         bsr    evaluate
  27.         bmi.w    illegal_addr
  28.         bgt.w    .norange
  29.         move.l    d0,d6
  30.         and.w    #$fffe,d6
  31. .norange    cmp.l    d5,d6
  32.         bls.w    illegal_addr
  33.  
  34.         move.l    d5,a0
  35.         move.l    d6,a1
  36.         bsr    search_cop
  37.         tst.l    d7
  38.         beq.b    .cop
  39.  
  40.         lea.l    copfailed_txt(pc),a0
  41.         bsr    print
  42.         bra.b    .out
  43.  
  44. .cop        lea.l    copfound_txt(pc),a0
  45.         bsr    print
  46.         moveq    #8,d1
  47.         move.l    custom+$80,d0
  48.         bsr    print_hexCR
  49.  
  50. .out        bra.w    end_command
  51.  
  52. copfailed_txt    dc.b "Couldn't find copper-list",$a,0
  53. copfound_txt    dc.b "Copper-list found at $",0
  54.         even
  55.  
  56.  
  57. ;-> a0-a1 = search range
  58. ;<- d0 = copper address
  59. ;<- d7 = success / failed
  60.  
  61. search_cop    movem.l    d1/a2,-(a7)
  62.         bsr    remove_pic
  63.         move.w    #$8380,$dff096
  64.         move.w    #$2700,sr
  65.  
  66.         moveq    #-1,d7
  67.  
  68.         moveq    #-2,d1
  69. .seek        cmp.l    a1,a0
  70.         bge.w    .end
  71.         cmp.l    (a0),d1
  72.         beq.b    .try
  73.         addq.l    #2,a0
  74.         bra.b    .seek
  75.  
  76. .try
  77.         move.l    a0,a2
  78.         addq.l    #2,a0
  79.  
  80.         subq.l    #4,a2
  81.         bsr    .test_cop
  82.         beq.b    .seek
  83.  
  84. .up        cmp.l    #$200,a2
  85.         blt.b    .down
  86.         lea.l    -$200(a2),a2
  87.         bsr    .test_cop
  88.         bne.b    .up
  89.  
  90. .down        lea.l    $20(a2),a2
  91.         bsr    .test_cop
  92.         beq.b    .down
  93.  
  94. .up2        subq.l    #4,a2
  95.         bsr    .test_cop
  96.         bne.b    .up2
  97.  
  98.         addq.l    #4,a2
  99.  
  100.         moveq    #0,d7
  101.         move.l    a2,d0
  102.         move.l    d0,custom+$80
  103.  
  104. .end        move.l    d0,-(a7)
  105.         moveq    #0,d0
  106.         jsr    analyse_copper
  107.         move.l    (a7)+,d0
  108.  
  109.         bsr    set_pic
  110.         move.w    #$80,$dff096
  111.         move.w    #$2000,sr
  112.         movem.l    (a7)+,d1/a2
  113.         rts
  114.  
  115. .test_cop    movem.l    d0/d6,-(a7)
  116.  
  117.         move.w    (a2),d0
  118.         btst    #0,d0
  119.         beq.b    .move
  120.         cmp.b    #$f0,d0
  121.         bhi.b    .nocop
  122.         bra.b    .okwait
  123. .move        tst.w    d0
  124.         beq.b    .nocop
  125.         cmp.w    #$1fe,d0
  126.         bls.b    .okwait
  127. .nocop        moveq    #0,d0
  128.         bra.b    .exittest
  129.  
  130. .okwait        move.w    #$10,$dff09c
  131.         move.l    (a2),d6
  132.         move.l    #$009c8010,(a2)
  133.         move.w    #$0,$dff088
  134.         move.b    #0,$bfe801
  135. .wait        cmp.b    #2,$bfe801
  136.         bls.b    .wait
  137.         move.w    $dff01e,d0
  138.         move.l    d6,(a2)
  139.         and.w    #$10,d0
  140. .exittest    movem.l    (a7)+,d0/d6
  141.         rts
  142.  
  143.  
  144. ;----------------------------------------------------------
  145. ;-------------- analyse the actual copper-list and --------
  146. ;-------------- update custom registers -------------------
  147.  
  148. ;-> d0=pic_no (stop the scan after the d0th write to $DFF100, 0=scan all)
  149.  
  150. analyse_copper    movem.l    d0-a4,-(a7)
  151.         move.w    d0,d6
  152.         bne.b    .okpara
  153.         moveq    #-1,d6
  154. .okpara        lea.l    custom,a3
  155.         move.l    $80(a3),d0    ;get copper 1 start
  156.         bsr.b    .analyse
  157.         movem.l    (a7)+,d0-a4
  158.         rts
  159.  
  160.  
  161. ;-> d0=ptr on copper-list
  162.  
  163. .analyse    lea.l    custom,a3
  164.         lea.l    paletteH-$180,a1
  165.         move.w    ($106,a3),d3
  166.         btst    #9,d3        ;low or high bits palette
  167.         beq.b    .high
  168.         lea.l    paletteL-$180,a1
  169. .high        rol.w    #3,d3
  170.         and.w    #%111,d3    ;d1=bank no.
  171.         lsl.w    #6,d3        ;*32*2
  172.         add.w    d3,a1
  173.  
  174.         lea.l    move_list,a2
  175.         btst    #0,d0
  176.         bne.w    .end        ;copper list at odd address ?
  177.         move.l    d0,a0
  178.  
  179. .loop        move.l    a0,a4
  180.         bsr    corr_addr
  181.         movem.w    (a4)+,d0/d1    ;read actual instr.
  182.         addq.l    #4,a0        ;go next instr.
  183.         btst    #0,d0        ;wait/skip or move instr. ?
  184.         bne.b    .waitinst
  185.  
  186.         cmp.w    #$200,d0    ;legal custom register ?
  187.         bcc.w    .end
  188.  
  189.         cmp.w    #$88,d0        ;cop1jmp ?
  190.         bne.b    .nojmp1
  191.         move.l    ($80,a3),a0    ;do the jmp to cop1
  192.         bra.b    .loop
  193. .nojmp1        cmp.w    #$8a,d0        ;cop2jmp ?
  194.         bne.b    .nojmp2
  195.         move.l    ($84,a3),a0    ;do the jmp to cop2
  196.         bra.b    .loop
  197.  
  198. .nojmp2        cmp.w    #$180,d0
  199.         blt.b    .nocolor
  200.         cmp.w    #$1be,d0
  201.         bgt.b    .nocolor
  202.         move.w    d1,(a1,d0.w)    ;copy in actual palette bank
  203.  
  204. .nocolor    cmp.w    #$106,d0
  205.         bne.b    .nobplcon3
  206.  
  207.         lea.l    paletteH-$180,a1
  208.         move.w    d1,d3
  209.         btst    #9,d3        ;low or high bits palette
  210.         beq.b    .high2
  211.         lea.l    paletteL-$180,a1
  212. .high2        rol.w    #3,d3
  213.         and.w    #%111,d3    ;d1=bank no.
  214.         lsl.w    #6,d3        ;*32*2
  215.         add.w    d3,a1
  216.  
  217. .nobplcon3    move.w    d0,d2
  218.         lsr.w    #1,d2
  219.         tst.b    (a2,d2.w)    ;do I need to copy this value ?
  220.         beq.b    .nocopy
  221.         move.w    d1,(a3,d0.w)    ;copy in custom
  222.         cmp.w    #$100,d0
  223.         bne.b    .no100
  224.         subq.w    #1,d6        ;dec(pic_no)
  225.         beq.b    .end
  226. .no100        bra.b    .nocopy
  227.  
  228. .waitinst    cmp.w    #$ffff,d0
  229.         beq.b    .end
  230.  
  231. .nocopy        bra.w    .loop
  232.  
  233. .end        rts
  234.  
  235.         cnop 0,4
  236. ;-------------- flags signaling registers to copy ---------
  237. ;-------------- from copper-list to custom ----------------
  238.  
  239. move_list    dcb.b $40,0        ;$000-$07e
  240.         dc.b -1,-1        ;$80,$82    ;cop1
  241.         dc.b -1,-1        ;$84,$86    ;cop2
  242.         dc.b 0,0,0        ;$88,$8a,$8c
  243.         dc.b -1,-1,-1,-1    ;$8e,$90,$92,$94
  244.         dcb.b $25,0        ;$96-$de
  245.         dcb.b $10,-1        ;$e0-$fe
  246.         dcb.b 7,-1        ;$100-$10c
  247.         dcb.b 9,0        ;$10e-$11e
  248.         dcb.b $10,-1        ;$120-$13e
  249.         dcb.b $20,0        ;$140-$17e
  250.         dcb.b $20,-1        ;$180-$1be
  251.         dcb.b $d,0        ;$1c0-$1d8
  252.         dc.b 0            ;$1da
  253.         dc.b -1            ;$1dc
  254.         dc.b -1,-1,-1        ;$1de-$1e2
  255.         dc.b -1            ;$1e4
  256.         dcb.b $b,0        ;$1e6-$1fa
  257.         dc.b -1            ;$1fc
  258.         dc.b 0            ;$1fe
  259. move_end
  260.  
  261.